traverse

inline fun <E, A, B> Either<E, A>.traverse(transform: (value: A) -> Iterable<B>): List<Either<E, B>>(source)
inline fun <E, A, B> Either<E, A>.traverse(transform: (value: A) -> Option<B>): Option<Either<E, B>>(source)


inline fun <E, A, B> Iterable<A>.traverse(f: (A) -> Either<E, B>): Either<E, List<B>>(source)

Returns an Either of a list of B results of applying the given transform function to each element(A) in the original collection.


inline fun <A, B> Iterable<A>.traverse(f: (A) -> Option<B>): Option<List<B>>(source)

Returns an Option of a list of B results of applying the given transform function to each element(A) in the original collection.


inline fun <E, A, B> Nel<A>.traverse(f: (A) -> Either<E, B>): Either<E, NonEmptyList<B>>(source)

Map a function that returns an Either across the NonEmptyList.

The first Left result from calling the function will be the result, or if no calls result in a Left the result will be a Right(NonEmptyList) of all the B's returned.


inline fun <A, B> NonEmptyList<A>.traverse(f: (A) -> Option<B>): Option<NonEmptyList<B>>(source)

Map a function that returns an Option across the NonEmptyList.

The first None result from calling the function will be the result, or if no calls result in a None the result will be a Some(NonEmptyList) of all the B's returned.


inline fun <T, E, U> Option<T>.traverse(f: (T) -> Either<E, U>): Either<E, Option<U>>(source)

Map a function that returns an Either across the Option.

If the option is a None, return a Right(None). If the option is a Some, apply f to the value. If f returns a Right, wrap the result in a Some.


inline fun <A, B> Option<A>.traverse(f: (A) -> Iterable<B>): List<Option<B>>(source)

Map a function that returns an Iterable across the Option.

If the option is a None, return an empty List If the option is a Some, apply f to the value and wrap the result in a Some.